﻿using System.Collections;
using System.Web.Routing;

namespace MvcSupplantCaching
{
    /// <summary>
    /// Interface for managing the <see cref="OutputCache"/> to allow for easy removal of cache items.
    /// </summary>
    public interface IOutputCacheManager
    {
        /// <summary>
        /// The <see cref="BaseOutputCacheProvider"/> used by this manager.
        /// </summary>
        BaseOutputCacheProvider OutputCacheProvider { get; }

        /// <summary>
        /// The <see cref="IKeyBuilder"/> used for this manager.
        /// </summary>
        IKeyBuilder KeyBuilder { get; }

        /// <summary>
        /// Implementations should remove a single output cache entry for the specified controller and action.
        /// </summary>
        /// <param name="controllerName">The name of the controller that contains the action method.</param>
        /// <param name="actionName">The name of the controller action method.</param>
        void RemoveItem(string controllerName, string actionName);

        /// <summary>
        /// Implementations should remove a single output cache entry for the specified controller, action and parameters.
        /// </summary>
        /// <param name="controllerName">The name of the controller that contains the action method.</param>
        /// <param name="actionName">The name of the controller action method.</param>
        /// <param name="routeValues">An object that contains the parameters for a route.</param>
        void RemoveItem(string controllerName, string actionName, object routeValues);

        /// <summary>
        /// Implementations should remove a single output cache entry for the specified controller, action and parameters.
        /// </summary>
        /// <param name="controllerName">The name of the controller that contains the action method.</param>
        /// <param name="actionName">The name of the controller action method.</param>
        /// <param name="routeValues">A dictionary that contains the parameters for a route.</param>
        void RemoveItem(string controllerName, string actionName, RouteValueDictionary routeValues);
        
        /// <summary>
        /// Implementations should remove all output cache entries.
        /// </summary>
        void RemoveItems();

        /// <summary>
        /// Implementations should remove all output cache entries for the specified controller.
        /// </summary>
        /// <param name="controllerName">The name of the controller.</param>
        void RemoveItems(string controllerName);

        /// <summary>
        /// Implementations should remove all output cache entries for the specified controller and action.
        /// </summary>
        /// <param name="controllerName">The name of the controller that contains the action method.</param>
        /// <param name="actionName">The name of the controller action method.</param>
        void RemoveItems(string controllerName, string actionName);

        /// <summary>
        /// Implementations should remove all output cache entries for the specified controller, action and parameters.
        /// </summary>
        /// <param name="controllerName">The name of the controller that contains the action method.</param>
        /// <param name="actionName">The name of the controller action method.</param>
        /// <param name="routeValues">A dictionary that contains the parameters for a route.</param>
        void RemoveItems(string controllerName, string actionName, RouteValueDictionary routeValues);

        /// <summary>
        /// The IDictionary act as a temporary or request duration cache for items that should be cached short term only.
        /// </summary>
        IDictionary RequestCache { get; }

        /// <summary>
        /// Adds a cache dependency on an output cached page.
        /// </summary>
        /// <param name="key">The dependency key.</param>
        void AddOutputCacheDependency(string key);

        /// <summary>
        /// Writes the output dependencies to the RequestCache
        /// </summary>
        void FinalizeDependencies();

        /// <summary>
        /// Expires the output cached pages for the given url.
        /// </summary>
        /// <param name="url">The url to expire cached pages for.</param>
        void ExpireOutputCacheForUrl(string url);
    }
}
